function StepHandler(startHandler, isThen, lastData) {
  this.then = (thenHandler) => { return this.thenStepHandler = new StepHandler(thenHandler, true, lastData); };
  (this.appendLastData = (lastData) => { this.lastData = lastData; return this })(lastData);
  this.start = () => { startHandler(
    this.lastData, 
    (thenLastData) => { this.thenStepHandler ? this.thenStepHandler.appendLastData(thenLastData).start() : ''; },
    (thenLastData) => { setTimeout(() => { this.thenStepHandler ? this.thenStepHandler.appendLastData(thenLastData).start() : '';},100)}) 
  };
  this.endSync = 
  isThen || this.start();
}
module.exports.StepHandler = StepHandler;


function localImage(netPath,countArray){
  return this.then(
    (data, end)=>{
      wx.getImageInfo({
        src: netPath, complete: (res) => {
          !countArray || countArray.push(res.path);
          end(res.path);
        }
      });
    }
  )
}
StepHandler.prototype.localImage = localImage;

function sync(thenHandler){
  return this.then((data, end) => { end(thenHandler(data)); });
}
StepHandler.prototype.sync = sync;
